#ifndef WAVE3DVIEW_H
#define WAVE3DVIEW_H
#include <QWidget>
#include <QGridLayout>
#include "wavelegend.h"
#include <QHash>

class CDataManage
{
public:
    CDataManage();
    virtual ~CDataManage();
protected:
    void resetUpdate(){m_bUpdateMax = false;}
    bool updateObj(){return m_yMax > 0 && m_bUpdateMax;}
    void clearData();
protected:
    float m_yMax; /*最大值数据*/
    int m_waveNum;
    bool m_bUpdateMax; /*最大值更新*/
    //数组操作和定义
protected:
    CLineLegend* ll;
    CPointLegend* pl;
};

class CAxisTextManage
{
public:
    CAxisTextManage();
    virtual ~CAxisTextManage();
    /**
     * @brief initAxisText  初始化网格个数和文本个数
     * @param vx  垂直于x轴个数
     * @param vy  垂直于y轴个数
     * @param vz  垂直于z抽个数
     */
    void initAxis(int vx, int vy, int vz);
protected:
    CAxisText* m_xText;
    CAxisText* m_yText;
    CAxisText* m_zText;
    CText2DTool* m_textTool;
};

class C3DView : public QOpenGLWidget, public QOpenGLFunctions_4_5_Core,
                   public CAxisTextManage, public CDataManage
{
    Q_OBJECT
public:
    explicit C3DView(QWidget *parent = nullptr);
    virtual ~C3DView();
    /**
     * @brief setBorderStyle  设置边框样式
     * @param style   样式
     * @return
     */
    virtual C3DView* setBorderStyle(PaintStyle style);
    /**
     * @brief setXTextStyle  设置x轴文本样式
     * @param style
     * @return
     */
    virtual C3DView* setXTextStyle(Text2DStyle style);
    /**
     * @brief setYTextStyle  设置y轴文本样式
     * @param style
     * @return
     */
    virtual C3DView* setYTextStyle(Text2DStyle style);
    /**
     * @brief setZTextStyle  设置z轴文本样式
     * @param style
     * @return
     */
    virtual C3DView* setZTextStyle(Text2DStyle style);
    /**
     * @brief setXNum  设置x轴的分段数量
     * @param xNum
     * @return
     */
    C3DView* setXNum(int xNum);
protected:
    virtual void paintBorder();
    virtual void paintGrid();
    virtual void paintPlan();
    virtual void paintAxisText();
protected:
    float m_xRange; /*相位轴*/
    float m_zRange; /*时间轴*/
    float m_yRange; /*振幅轴*/
    Point3d m_valScole; /*根据数量缩放值*/
    PaintStyle m_GridStyle;
    PaintStyle m_BorderStyle;
    bool bUpdateYTexture;
private:
    float m_scloe;
    /* 鼠标按下坐标参数*/
    Point3d m_press;
    /* 窗口位移参数*/
    Point3d m_rot1;
    Point3d m_rot2;
    /* 三维坐标系位移参数*/
    Point3d m_translate;
protected:
    virtual void initializeGL();
    virtual void resizeGL(int w, int h);
    virtual void paintGL();
    virtual void mousePressEvent(QMouseEvent *event);
    virtual void mouseReleaseEvent(QMouseEvent *event);
    virtual void mouseMoveEvent(QMouseEvent *event);
    virtual void wheelEvent(QWheelEvent *event);
signals:
};

#endif // WAVE3DVIEW_H
